package com.yuer.tools.myfileziptools.test;


import java.util.Scanner;

public class Student{
    private int id;
    private String name;
    public Student(int id,String name){
        setId(id);
        setName(name);
    }
    public int getId(){
        return id;
    }
    public void setId(int id){
        if(id>0){
            this.id=id;
        }else{
            System.out.println("输入的学号不正确");
        }
    }
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name=name;
    }
    public void show(){
        System.out.println("姓名:"+getName()+",学号:"+getId());
    }
    public static void main(String[] args){
        System.out.println("请输入学生人数:");
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        Student[] arr=new Student[num];
        for(int i=0;i<num;i++){
            System.out.println("请输入第"+(i+1)+"个学生的姓名和学号:");
            arr[i]=new Student(sc.nextInt(),sc.next());
        }
        System.out.println("该班的所有学生信息:");
        for(int i=0;i<num;i++){
            arr[i].show();
        }
    }

}